//
//  CDSettingPF.m
//  CuriosityDaily3
//
//  Created by donghao on 16/9/24.
//  Copyright © 2016年 theBestTeam. All rights reserved.
//

#import "CDSettingPF.h"

@implementation CDSettingPF

+ (instancetype)sharedSettingPF {
    
    static CDSettingPF *instance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [self new];
//        NSLog(@"%@",instance);
        // 判断偏好设置中是否有key
        if (nil != [[NSUserDefaults standardUserDefaults] objectForKey:@"fontSize"]) {
            instance.fontSize = [[NSUserDefaults standardUserDefaults] valueForKey:@"fontSize"];
        } else {
            instance.fontSize = @16;
        }
        if (nil != [[NSUserDefaults standardUserDefaults] objectForKey:@"update"]) {
            instance.update = [[NSUserDefaults standardUserDefaults] valueForKey:@"update"];
        } else {
            
            instance.update = @NO;
        }
        if (nil !=[[NSUserDefaults standardUserDefaults] objectForKey:@"comment"]) {
            instance.comment = [[NSUserDefaults standardUserDefaults] valueForKey:@"comment"];
//            NSLog(@"%@",instance.comment);
        } else {
            
            instance.comment = @NO;
        }
    });
    return instance;
}

#pragma mark - 在赋值的时候，保存的偏好设置当中
- (void)setUpdate:(NSNumber *)update {
    _update = update;
    [[NSUserDefaults standardUserDefaults] setValue:update forKey:@"update"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (void)setComment:(NSNumber *)comment {
    _comment = comment;
    [[NSUserDefaults standardUserDefaults] setValue:comment forKey:@"comment"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (void)setFontSize:(NSNumber *)fontSize {
    _fontSize = fontSize;
   [[NSUserDefaults standardUserDefaults] setValue:fontSize forKey:@"fontSize"];
    [[NSUserDefaults standardUserDefaults] synchronize];    
}



@end
